const state = {
  // 吐司
  TOAST: false,
  // 提示
  TIP: false,
  // 信息提示
  MSG: {},
  // 菜单列表
  MENULIST: [],
  // 菜单权限
  MENUSCOPE: "",
  USERID: null,
  USERTYPE: null,
  ROLEID: null,
  // 用户退出时需要的编码
  USERCODE: null,
  NAVTOGGLE: true,
  imgURL: "",
};
const mutations = {
  imgURLModel(state, option) {
    state.imgURL = option;
  },
  totasModel(state, option) {
    state.TOAST = option;
  },
  tipModel(state, option) {
    state.TIP = option;
  },
  msgModel(state, option) {
    state.MSG = option;
  },
  menuList(state, option) {
    state.MENULIST = option.menu;
  },
  menuScope(state, option) {
    state.MENUSCOPE = option.scope;
  },
  setUserInfo(state, option) {
    state.USERID = option.userId;
    state.USERTYPE = option.userType;
    state.ROLEID = option.roleId;
  },
  setUserCode(state, option) {
    state.MENUSCOPE = option.userCode;
  },
  setNavToggle(state, option) {
    state.NAVTOGGLE = option.toggleFlag;
  },
};
const actions = {
  totasModel(context, option) {
    context.commit("totasModel", option);
  },
  tipModel(context, option) {
    context.commit("tipModel", option);
  },
  msgModel(context, option) {
    context.commit("msgModel", option);
  },
  setMenu(context, option) {
    context.commit("menuList", option);
  },
  setMenuScope(context, option) {
    context.commit("menuScope", option);
  },
  setUserInfo(context, option) {
    context.commit("setUserInfo", option);
  },
  setUserCode(context, option) {
    context.commit("setUserCode", option);
  },
  setNavToggle(context, option) {
    context.commit("setNavToggle", option);
  },
};

export default {
  // namespaced: true, // 命名可重复
  state,
  mutations,
  actions,
  // getters
};
